package org.veridiandynamics.client.view;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import javax.swing.Box;
import javax.swing.JLabel;
import javax.swing.JButton;

/**
 * This class generates guis for system administrators that provide 
 * links to adding users, resetting passwords and suspending accounts.
 * 
 * @author Lee
 */
public class AdminPanel extends AbstractPanelLayout
{
	private static final long serialVersionUID = 1L;
	private JButton viewNurseOperations;
	private JButton viewDoctorOperations;
	private AdminPanel thisPanel;
	
	/**
	 * Constructor for the admin panel.  This initializes everything 
	 * on the screen.
	 */
	public AdminPanel() 
	{
		thisPanel = this;
		numCenterPanels = 1;
		initialize();
		
		
		JPanel subLeft = new JPanel();
		
		subLeft.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,},
			new RowSpec[] {
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,}));
		
		JLabel lblAddEdit = new JLabel("1.  Add, edit or delete users");
		subLeft.add(lblAddEdit, "4, 4");
		
		JLabel lblSuspendunsuspsendAccount = new JLabel("2.  Suspend/Unsuspsend account");
		subLeft.add(lblSuspendunsuspsendAccount, "8, 4");
		
		JLabel lblSetresetPasswords = new JLabel("3.  Set/reset passwords");
		subLeft.add(lblSetresetPasswords, "12, 4");
		
		panelLeft.add(subLeft);
		
		JButton btnAddEditOr = new JButton("Add, edit, or delete");
		btnAddEditOr.addActionListener(new ActionListener()
		{
			/**
			 * This method moves the user to the adduser panel.
			 * 
			 * @param event The ActionEvent object handling the listening.
			 */
			public void actionPerformed(ActionEvent event)
			{
				AddUser addUser = new AddUser(c1, thisPanel);
				add(addUser, "USERCARD");
				c1.show(thisPanel, "USERCARD");
			}
		});
		subLeft.add(btnAddEditOr, "4, 8");
		
		JButton btnSuspendUnsuspend = new JButton("suspend/ unsuspend");
		btnSuspendUnsuspend.addActionListener(new ActionListener()
		{
			/**
			 * This method moves the user to the suspend accounts panel.
			 * 
			 * @param event The ActionEvent object handling the listening.
			 */
			public void actionPerformed(ActionEvent event)
			{
				SuspendAccountsPanel susPanel = new SuspendAccountsPanel(c1, thisPanel);
				add(susPanel, "SUSPENDCARD");
				c1.show(thisPanel, "SUSPENDCARD");
			}
		});
		subLeft.add(btnSuspendUnsuspend, "8, 8");
		
		JButton btnSetreset = new JButton("Set/reset");
		btnSetreset.addActionListener(new ActionListener()
		{
			/**
			 * This method moves the user to the set passwords panel.
			 * 
			 * @param event The ActionEvent object handling the listening.
			 */
			public void actionPerformed(ActionEvent event)
			{
				SetPasswords pass = new SetPasswords(c1, thisPanel);
				add(pass, "PASSWORDCARD");
				c1.show(thisPanel, "PASSWORDCARD");
			}
		});
		subLeft.add(btnSetreset, "12, 8");
		
		JPanel subLeft2 = new JPanel();
		subLeft2.add(Box.createRigidArea(new Dimension(0, 200)));
		viewNurseOperations = new JButton("View Nurse Operations");
		viewDoctorOperations = new JButton("View Doctor Operations");
		
		panelLeft.add(subLeft2);

	}

}
